package com.myapplication.interfaces;

import com.myapplication.callback.ShopCartCallback;
import com.myapplication.http.util.HttpFail;
import com.myapplication.http.util.Util;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by zhoushikun on 2016/7/12.
 */
public class ShopCartConnect implements ShopCartInter {
    @Override
    public void getShopCartInfo(String key, final ShopCartCallback shopCartCallback) {
        RequestParams params = new RequestParams(Util.UrlShopCart);
        params.addBodyParameter("key", key);
        x.http().get(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                shopCartCallback.onShopCartSuccess(result);
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {

                shopCartCallback.onShopCartFail(HttpFail.onError(ex,isOnCallback));
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }
}
